package com.example.auv_660.util;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

import com.example.auv_660.MainActivity;


import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Tools {



    public static String DateFormat(Date date, String choice) {
        DateFormat df = null;
        if (choice.equals("s")) {
            df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
        } else {
            df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-S");
        }
        if (date != null && df != null) {
            return df.format(date);
        }
        return null;
    }

    public static String getTime(long curTime) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        String curT = dateFormat.format(new Date(curTime));
        return curT;
    }

    public static Display getDisplay() {
        WindowManager wm = (WindowManager) MainActivity.getInstance()
                .getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
        assert wm != null;
        return wm.getDefaultDisplay();
    }

    public static DisplayMetrics getRealMetrics() {
        DisplayMetrics metrics = new DisplayMetrics();
        getDisplay().getRealMetrics(metrics);
        return metrics;
    }
}
